#include "qerrorline.h"

QErrorLine::QErrorLine(QList<QEXPPart*> parts,QErreur* error,QObject* parent)
	:m_parts(parts),m_error(error)
{
	#ifdef	LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef	LEAK_ACTIVATED
	__LEAK__
	#endif
}

QErrorLine::QErrorLine(QEXPPart* part,QErreur* error)
	:m_error(error)
{
  #ifdef  LOG_ACTIVATED
  __TRACE__
  #endif
  #ifdef  LEAK_ACTIVATED
  __LEAK__
  #endif
  m_parts << part;
}

QErrorLine::~QErrorLine()
{
	#ifdef	LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef	LEAK_ACTIVATED
	__LEAK__
	#endif
}

QString QErrorLine::description() const
{
  #ifdef  LOG_ACTIVATED
  __TRACE__
  #endif
  #ifdef  LEAK_ACTIVATED
  __LEAK__
  #endif
  QList<quint32> lines;
  foreach(QEXPPart* part,m_parts)
  {
	if(part)
		lines << part->line();
  }
  return m_error->description(lines);
}


QStringList QErrorLine::designators() const
{
	#ifdef  LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef  LEAK_ACTIVATED
	__LEAK__
	#endif
	QStringList designators;
	foreach(QEXPPart* part,m_parts)
	{
		if(part)
			designators << part->get(EXP_ID);
	}
	return designators;
}

quint32 QErrorLine::importance() const
{	
	#ifdef  LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef  LEAK_ACTIVATED
	__LEAK__
	#endif
	if(m_error)
		return m_error->importance();
	else
		return 0;
}

QList<quint32> QErrorLine::lines() const
{
	#ifdef  LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef  LEAK_ACTIVATED
	__LEAK__
	#endif
	QList<quint32> lines;
	 foreach(QEXPPart* part,m_parts)
	 {
		if(part)
			lines << part->line();
	 }
	 return lines;
}

QString QErrorLine::id() const
{
	#ifdef  LOG_ACTIVATED
	__TRACE__
	#endif
	#ifdef  LEAK_ACTIVATED
	__LEAK__
	#endif
	if(m_error)
		return m_error->key();
	return QString();
}

QList<QEXPPart*> QErrorLine::parts() const
{
	return m_parts;
}



void QErrorLine::addPart(QEXPPart* part)
{
	m_parts << part;
}


QEXPPart* QErrorLine::firstPart() const
{
	if(m_parts.size())
		return m_parts.first();
	return NULL;
}